#include "widget.h"
#include <QLabel>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QFormLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    setMaximumSize(400, 300);
    setMinimumSize(400, 300);

    QLabel* label_user = new QLabel(this);
    label_user->setText("账号");
    label_user->setMaximumWidth(30);
    QComboBox* comboBox_user = new QComboBox(this);
    comboBox_user->setEditable(true);

    //账号水平布局器
    QHBoxLayout* hBoxLayout_user = new QHBoxLayout;
    hBoxLayout_user->addWidget(label_user);
    hBoxLayout_user->addWidget(comboBox_user);


    QLabel* label_password = new QLabel(this);
    label_password->setText("密码");
    label_password->setMaximumWidth(30);
    QLineEdit* lineEdit_password = new QLineEdit(this);

    //密码水平布局器
    QHBoxLayout* hBoxLayout_password = new QHBoxLayout;
    hBoxLayout_password->addWidget(label_password);
    hBoxLayout_password->addWidget(lineEdit_password);

    QPushButton* pushButton = new QPushButton(this);
    pushButton->setText("登录");

    //登录按钮水平布局器
    QHBoxLayout* hBoxLayout_login = new QHBoxLayout;
    hBoxLayout_login->addStretch(1);
    hBoxLayout_login->addWidget(pushButton, 2);
    hBoxLayout_login->addStretch(1);

    //ip, port表格布局器
    QFormLayout* formLayout = new QFormLayout;
    formLayout->addRow("ip", new QLineEdit(this));
    formLayout->addRow("port", new QLineEdit(this));

    //窗口的顶级布局器
    QVBoxLayout* vBoxLayout = new QVBoxLayout(this);
    vBoxLayout->addLayout(hBoxLayout_user);
    vBoxLayout->addLayout(hBoxLayout_password);
    vBoxLayout->addLayout(formLayout);
    vBoxLayout->addLayout(hBoxLayout_login);
    vBoxLayout->setContentsMargins(50, 100, 50, 30);



}

Widget::~Widget()
{

}
